package com.cykj.chat.config;

import com.cykj.webSocket.AddWebSocketHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.WebSocketHandler;
import org.springframework.web.socket.config.annotation.EnableWebSocket;
import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;

/**
 * @BelongsProject: smart_recruit_backend
 * @BelongsPackage: com.cykj.chat.config
 * @Author: 蔡张君逸
 * @CreateTime: 2025-08-27 11:28
 * @Description: TODO
 * @Version: 1.0
 */
@Configuration
@EnableWebSocket
public class WebSocketConfig implements WebSocketConfigurer {
    @Autowired
    AddWebSocketHandler addWebSocketHandler;
    @Override
    public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
//        setAlloewedOrigins 指定前端来源页面
        registry.addHandler(addWebSocketHandler,"/ws").setAllowedOrigins("*");

    }
}